package com.example.springbootpay.controller;

import com.example.springbootpay.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/payment")
public class PaymentController {

    private final PaymentService paymentService;

    @Autowired
    public PaymentController(PaymentService paymentService) {
        this.paymentService = paymentService;
    }

    @PostMapping("/unifiedOrder")
    public String unifiedOrder(@RequestParam Integer amount) {
        return paymentService.unifiedOrder(amount);
    }

    @GetMapping("/orderQuery")
    public String orderQuery(@RequestParam String orderId) {
        return paymentService.orderQuery(orderId);
    }

    @PostMapping("/refund")
    public String refund(@RequestParam String orderId, @RequestParam Integer amount) {
        return paymentService.refund(orderId, amount);
    }
}